//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    manageList:[
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_1.png?sign=e2242775190101921b3c8a2adc5683b1&t=1605175572",title:"问诊管理",url:"/hyb_yl/jigou/pages/docorder/docorder"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_5.png?sign=54d35d4356d55ba73fc48dbd879fec53&t=1605175590",title:"订单管理",url:"/hyb_yl/jigou/pages/docorder/docorder?keyword=goods"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_4.png?sign=ae4cfe5a1da898023564310fc3939fe3&t=1605175597",title:"数据总览",url:"/hyb_yl/jigou/pages/all_data/all_data"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_3.png?sign=e16177c033b1b090e6167b831ba0b5ec&t=1605175605",title:"手术管理",url:"/hyb_yl/jigou/pages/docorder/docorder?keyword=shoushukuaiyue"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_6.png?sign=a88ff89b5a2fbe0321f4c5063176347b&t=1605175613",title:"挂号管理",url:"/hyb_yl/jigou/pages/docorder/docorder?keyword=yuanchengguahao"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_2.png?sign=896bb80d230cb12a64e65116765fddfa&t=1605175580",title:"患者管理",url:"/hyb_yl/jigou/pages/patient/patient"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_7.png?sign=ee0667abb59b2e9c9651c0ebb98da060&t=1605175624",title:"产品管理",url:"/hyb_yl/jigou/pages/shopType/shopType"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_8.png?sign=a75693d1670aba47a409e4a338146537&t=1605175631",title:"套餐管理",url:"/hyb_yl/jigou/pages/hot-sale/hot-sale"},
      {img:"https://696d-image-ac66k-1302520890.tcb.qcloud.la/icon_9.png?sign=62fa7d6e3ae51f76f63cb1dfa1cb4aeb&t=1605175641",title:"资料管理",url:"/hyb_yl/jigou/pages/settlement/settlement"},
    ],
  },
  toorder:function(e){
    wx.navigateTo({
      url: '/hyb_yl/jigou/pages/docorder/docorder?keyword='+e.currentTarget.dataset.key_words,
    })
  },
  // 工作管理跳转页面
  go_back:function(e){
    var url=e.currentTarget.dataset.url
    wx.navigateTo({
      url: url,
    })
  },
  onLoad: function () {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
    var that = this;
    that.getHospital();
  },
  // 获取机构详情
  getHospital:function(){
    var that = this;
    app.util.request({
      'url':"enctry/wxapp/regin.jigouif",
      data:{
        openid:wx.getStorageSync('openid'),
      },
      success:function(res){
        that.setData({
          info:res.data
        })
      }
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
